var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("GlobalParams"),
    i = e("AudioManager"),
    r = e("CommonHelper"),
    s = e("AD"),
    l = e("shop_dower_item_node"),
    c = cc._decorator,
    d = c.ccclass,
    h = c.property,
    _ = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.dower_content_node = null),
                (t.dower_node_item = null),
                (t.update_btn = null),
                (t.dower_discount = [1, 0.95, 0.9, 0.85, 0.8]),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                this.node.getComponent(cc.ScrollView).scrollToLeft(0.1);
            }),
            (t.prototype.addEvent = function () {
                this.update_btn.on("click", this.updateShopDowerInfo, this);
            }),
            (t.prototype.start = function () {
                this.showDowerInfo();
            }),
            (t.prototype.showDowerInfo = function () {
                for (var e = a.GlobalParams.ShopDowerInfo.value, t = [], o = 0; o < 8; o++) {
                    var n = null;
                    e.now_date != new Date().toLocaleDateString()
                        ? (((n = {
                              dower: r.default.getRandomInt(0, 4),
                              num: 0 == o ? 1 : r.default.getRandomInt(1, 5),
                              discount: 1,
                              type: r.default.getRandomInt(0, 1),
                              is_buy: !1
                          }).discount = this.dower_discount[n.num - 1]),
                          t.push(n))
                        : (n = e.info[o]);
                    var i = null;
                    this.dower_content_node.children[o]
                        ? (i = this.dower_content_node.children[o])
                        : (i = cc.instantiate(this.dower_node_item)).setParent(this.dower_content_node),
                        i.getComponent(l.default).showDowerInfo(n, o),
                        (i.active = !0);
                }
                e.now_date != new Date().toLocaleDateString() &&
                    ((e.info = t),
                    1 != e.now_date && (e.free = !0),
                    (e.now_date = new Date().toLocaleDateString()),
                    (a.GlobalParams.ShopDowerInfo.value = e)),
                    (this.update_btn.children[0].active = e.free),
                    (this.update_btn.children[1].active = !e.free);
            }),
            (t.prototype.updateShopDowerInfo = function () {
                var e = this;
                i.default.ButtonSound(), this.node.getComponent(cc.ScrollView).scrollToLeft(0.1);
                var t = a.GlobalParams.ShopDowerInfo.value,
                    o = function () {
                        (t.free = !1), (t.now_date = 1), e.showDowerInfo();
                    };
                t.free
                    ? o()
                    : s.default.getInstance().showVideo(function (e) {
                          i.default.playGameBGM(), e == s.ResultEnum.Success && o();
                      });
            }),
            __decorate([h(cc.Node)], t.prototype, "dower_content_node", void 0),
            __decorate([h(cc.Node)], t.prototype, "dower_node_item", void 0),
            __decorate([h(cc.Node)], t.prototype, "update_btn", void 0),
            __decorate([d], t)
        );
    })(n.default);
o.default = _;
